package com.evry.finance.collateral.wsdomain;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.UnexpectedInputException;

import com.edb.finance.collateral.wsdomain.collateralitem.v1.Collateralitem;

public class QueueReader implements ItemReader<Collateralitem> {

	private BlockingQueue<Collateralitem> queue;
	
	public Collateralitem read() throws Exception, UnexpectedInputException {
		Collateralitem item = queue.poll(20, TimeUnit.SECONDS);
		if(item == null){
			System.out.println("Listan �r tom.");
		}
		return item;
	}
	
	public void setQueue(BlockingQueue<Collateralitem> queue) {
		this.queue = queue;
	}
}